﻿using System;

using System.Collections.Generic;
using System.Text;
using Fluid.Controls;
using System.Drawing;
using PasswordSafe.Classes;

namespace PasswordSafe
{
    public class SearchPanel : NumericPad
    {

        private static SearchPanel instance;
        public static SearchPanel Instance
        {
            get
            {
                instance = new SearchPanel();
                return instance;
            }
        }


        protected override void InitControl()
        {
            base.InitControl();
            MakeButtonsGlowing();
            Bounds = new Rectangle(0, 0, 240, 120);
          //  Anchor = AnchorBLR;
         //   Alpha = 230;  // <-- doesn't look good
            EnableDoubleBuffer = true;
        }

        private void MakeButtonsGlowing()
        {
            FluidButton[] buttons = this.Buttons;
            buttons[15].Text = "Close";
            foreach (FluidButton btn in buttons) btn.PressedBackColor = Color.DarkBlue;
            //buttons[11].PressedBackColor = Color.Red;
            buttons[15].PressedBackColor = Color.Green;
        }


        protected override void OnEnter()
        {
            base.OnEnter();           
            this.Close();
        }

        protected override void OnTextChanged()
        {
            base.OnTextChanged();
            ListBuilder.Instance.Filter(Text);
        }


        public override void Show(ShowTransition transition)
        {
            Height = ScaleY(120);
            base.Show(transition);
        }

        public override void Close(ShowTransition transition)
        {
            Text = "";
            base.Close(transition);
            Browser.Instance.Focus();
        }


    }
}
